module WallaceTree (
    input [49:0]PProduct_0,
    input [49:0]PProduct_1,
    input [49:0]PProduct_2,
    input [49:0]PProduct_3,
    input [49:0]PProduct_4,
    input [49:0]PProduct_5,
    input [49:0]PProduct_6,
    input [49:0]PProduct_7,
    input [49:0]PProduct_8,
    input [49:0]PProduct_9,
    input [49:0]PProduct_10,
    input [49:0]PProduct_11,
    input [49:0]PProduct_12,
    output [49:0]product_out
);
    wire [49:0]PProduct_0_shift;
    wire [49:0]PProduct_1_shift;
    wire [49:0]PProduct_2_shift;
    wire [49:0]PProduct_3_shift;
    wire [49:0]PProduct_4_shift;
    wire [49:0]PProduct_5_shift;
    wire [49:0]PProduct_6_shift;
    wire [49:0]PProduct_7_shift;
    wire [49:0]PProduct_8_shift;
    wire [49:0]PProduct_9_shift;
    wire [49:0]PProduct_10_shift;
    wire [49:0]PProduct_11_shift;
    wire [49:0]PProduct_12_shift;

    assign PProduct_0_shift=PProduct_0;
    assign PProduct_1_shift=PProduct_1<<2;
    assign PProduct_2_shift=PProduct_0<<4;
    assign PProduct_3_shift=PProduct_0<<6;
    assign PProduct_4_shift=PProduct_0<<8;
    assign PProduct_5_shift=PProduct_0<<10;
    assign PProduct_6_shift=PProduct_0<<12;
    assign PProduct_7_shift=PProduct_0<<14;
    assign PProduct_8_shift=PProduct_0<<16;
    assign PProduct_9_shift=PProduct_0<<18;
    assign PProduct_10_shift=PProduct_0<<20;
    assign PProduct_11_shift=PProduct_0<<22;
    assign PProduct_12_shift=PProduct_0<<24;

    wire [49:0]c_l11;
    wire [49:0]s_l11;
    wire [49:0]c_l12;
    wire [49:0]s_l12;
    wire [49:0]c_l13;
    wire [49:0]s_l13;
    wire [49:0]c_l14;
    wire [49:0]s_l14;

    wire [49:0]c_l21;
    wire [49:0]s_l21;
    wire [49:0]c_l22;
    wire [49:0]s_l22;
    wire [49:0]c_l23;
    wire [49:0]s_l23;

    wire [49:0]c_l31;
    wire [49:0]s_l31;
    wire [49:0]c_l32;
    wire [49:0]s_l32;

    wire [49:0]c_l4;
    wire [49:0]s_l4;

    wire [49:0]c_l5;
    wire [49:0]s_l5;
    //layer 1
    CSA CSA_l11(
        .pp1(PProduct_0),
        .pp2(PProduct_1),
        .pp3(PProduct_2),
        .C(c_l11),
        .S(s_l11)
    );

    CSA CSA_l12(
        .pp1(PProduct_3),
        .pp2(PProduct_4),
        .pp3(PProduct_5),
        .C(c_l12),
        .S(s_l12)
    );

        CSA CSA_l13(
        .pp1(PProduct_6),
        .pp2(PProduct_7),
        .pp3(PProduct_8),
        .C(c_l13),
        .S(s_l13)
    );

        CSA CSA_l14(
        .pp1(PProduct_9),
        .pp2(PProduct_10),
        .pp3(PProduct_11),
        .C(c_l14),
        .S(s_l14)
    );

    //layer 2

        CSA CSA_l21(
        .pp1(PProduct_12),
        .pp2(c_l11<<1),
        .pp3(s_l11),
        .C(c_l21),
        .S(s_l21)
    );

        CSA CSA_l22(
        .pp1(c_l12<<1),
        .pp2(s_l12),
        .pp3(c_l13<<1),
        .C(c_l22),
        .S(s_l22)
    );

        CSA CSA_l23(
        .pp1(s_l14),
        .pp2(c_l14<<1),
        .pp3(s_l13),
        .C(c_l23),
        .S(s_l23)
    );

    //layer 3
        CSA CSA_l31(
        .pp1(s_l21),
        .pp2(c_l21<<1),
        .pp3(s_l22),
        .C(c_l31),
        .S(s_l31)
    );
        CSA CSA_l32(
        .pp1(s_l23),
        .pp2(c_l22<<1),
        .pp3(c_l23<<1),
        .C(c_l32),
        .S(s_l32)
    );

    //
            CSA CSA_l4(
        .pp1(s_l31),
        .pp2(c_l31<<1),
        .pp3(c_l32<<1),
        .C(c_l4),
        .S(s_l4)
    );

    //
            CSA CSA_l5(
        .pp1(s_l4),
        .pp2(c_l4<<1),
        .pp3(s_l32),
        .C(c_l5),
        .S(s_l5)
    );
endmodule